package com.lc.afbx.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

import com.lc.afbx.BaseApplication;
import com.lc.afbx.R;
import com.lc.afbx.conn.GetApiCommissionExtract;
import com.lc.afbx.conn.GetApiYiTiXian;
import com.lc.afbx.util.TimeUtil;
import com.zcx.helper.util.UtilLog;
import com.zcx.helper.util.UtilToast;

import java.util.List;

/**
 * Created by Administrator on 2016/6/7.
 */
public class ExtractedAdapter extends BaseAdapter {
    private List<GetApiYiTiXian.Data> dataList;
    private LayoutInflater inflater;
    private Context context;

    public ExtractedAdapter(Context context, List<GetApiYiTiXian.Data> dataList) {
        inflater = LayoutInflater.from(context);
        this.dataList = dataList;
        this.context = context;
    }


    @Override
    public int getCount() {
        return dataList.size();
    }

    @Override
    public Object getItem(int position) {
        return dataList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;
        if (convertView == null) {

            convertView = inflater.inflate(R.layout.item_extractedmingxi, null);
            BaseApplication.ScaleScreenHelper.loadView((ViewGroup) convertView);
            holder = new ViewHolder();

            holder.txt_time = (TextView) convertView.findViewById(R.id.txt_time);

            holder.txt_keTiXian = (TextView) convertView.findViewById(R.id.txt_keTiXian);
            holder.txt_tuiJian = (TextView) convertView.findViewById(R.id.txt_tuiJian);
            holder.txt_product = (TextView) convertView.findViewById(R.id.txt_product);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        UtilLog.e("佣金Adapter里", dataList.get(position).client + dataList.get(position).products + "");
        holder.txt_keTiXian.setText(dataList.get(position).price);
        holder.txt_tuiJian.setText(dataList.get(position).client);
        holder.txt_product.setText(dataList.get(position).products);


        holder.txt_time.setText(TimeUtil.times(dataList.get(position).posttime));

        return convertView;
    }

    class ViewHolder {
        TextView txt_keTiXian, txt_tuiJian, txt_product, txt_time;

    }
}
